/*
day483 
2020.12.23 
*/
#include<iostream>
#include<vector>
#include<stack>
#include<cstring>
using namespace std;

class Solution {
public:
    string removeOuterParentheses(string S) {
		stack<char> sta;
		vector<char> vec;
		vector<char> tem;
		for(int i=0;i<S.size();++i)
		{
			tem.push_back(S[i]);
			if(S[i]=='(')
			{
				sta.push(S[i]);
			}
			else 
			{
				if(sta.size()==1)
				{
					for(int j=1;j<tem.size()-1;++j)
					{
						vec.push_back(tem[j]);
					}
					tem.erase(tem.begin(),tem.end());
				}
				sta.pop();
			}
		}
		
		string res(vec.begin(),vec.end());
		return res;
    }
};


int main()
{
	return 0;
}
